<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>水平元素居中</title>
  </head>
  <style>
    .wrapper {
      width: 100%;
      height: 500px;

      text-align: center; /* 3 */
    }
    .center {
      width: 500px;
      text-align: left;
      margin: 0 auto;

      background-color: orange;
    }
  </style>
  <body>
    <div class="wrapper">
      <div class="center">
        父元素上设置 text-align: center;<br />
        居中元素上margin 为 auto。
      </div>
    </div>
  </body>
</html>
